package com.example.demo.controller;

import com.example.demo.entity.Student;
import com.example.demo.service.StudentService;
import com.example.demo.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: Tian
 * @version: 1.0
 * @since: 1.0
 * @date: 2024/4/16/18:49
 */
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    StudentService studentServiceImpl;

    @GetMapping("/selectStudents/{current}/{pageSize}")
    public Result selectAll(@PathVariable Integer current,@PathVariable Integer pageSize) {
        return studentServiceImpl.selectAll(current,pageSize);
    }

    @PostMapping("/insertStudent")
    public Result insertStudent(@RequestBody Student student){
        System.out.println(student);
        return studentServiceImpl.insertStudent(student);
    }
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        System.out.println(id);
        return studentServiceImpl.deleteById(id);
    }
    @PutMapping("/update")
    public Result update(@RequestBody Student student){
        System.out.println(student);
        return studentServiceImpl.update(student);
    }
}
